{template '_header'}

<div class="page-header">
    当前位置：<span class="text-primary">{if !empty($level['id'])}编辑{else}添加{/if}会员等级{if !empty($level['id'])}({$level['levelname']}){/if}</span>
</div>

<div class="page-content">
    <div class="page-sub-toolbar">
        <span class=''>
            {ifp 'user.level.add'}
                <a class="btn btn-primary btn-sm" href="{php echo webUrl('user/level/add')}">添加新会员等级</a>
            {/if}
        </span>
    </div>
<form {ife 'user.level' $level}action="" method="post"{/if} class="form-horizontal form-validate" enctype="multipart/form-data">
    <input type="hidden" name="id" value="{$level['id']}" />

    {if $id!='default'}
    <div class="form-group">
        <label class="col-sm-2 control-label">等级</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'user.level' $level}
            <select  name="level" class="form-control tp_is_default" style="width:90px;">
                {loop $level_array $key $value}
                <option value="{$value}" {if $level['level']==$value}selected{/if}>{$value}</option>
                {/loop}
            </select>

            <span class='help-block'>数字越大等级越高</span>
            {else}
            <div class='form-control-static'>{$level['level']}</div>
            {/if}
        </div>
    </div>
    {/if}
    <div class="form-group">
        <label class="col-sm-2 control-label must"> {if $id=='default'}默认{/if}等级名称</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'user.level' $level}
            <input type="text" name="levelname" class="form-control" value="{$level['levelname']}" data-rule-required="true" />
            {else}
            <div class='form-control-static'>{$level['levelname']}</div>
            {/if}
        </div>
    </div>
    {if $id!='default'}
    <div class="form-group">
        <label class="col-sm-2 control-label">升级条件</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'user.level' $level}
            <div class='input-group'>
                {if empty($set['shop']['leveltype'])}
                <span class='input-group-addon'>完成订单金额满</span>
                <input type="text" name="ordermoney" class="form-control" value="{$level['ordermoney']}" />
                <span class='input-group-addon'>元</span>
                {/if}
                {if $set['shop']['leveltype']==1}
                <span class='input-group-addon'>完成订单数量满</span>
                <input type="text" name="ordercount" class="form-control" value="{$level['ordercount']}" />
                <span class='input-group-addon'>个</span>

                {/if}
            </div>
            <span class='help-block'>会员升级条件，不填写默认为不自动升级, 设置<a href="{php echo webUrl('sysset/member')}">【会员升级依据】</a> </span>
            {else}
            <div class='form-control-static'>

                {if empty($shopset['leveltype'])}
                {if $level['ordermoney']>0}
                完成订单金额满 {$level['ordermoney']}元
                {else}
                不自动升级
                {/if}
                {/if}
                {if $shopset['leveltype']==1}
                {if $level['ordercount']>0}
                完成订单数量满 {$level['ordercount']}个
                {else}
                不自动升级
                {/if}
                {/if}

            </div>
            {/if}
        </div>
    </div>
    {/if}
    <div class="form-group">
        <label class="col-sm-2 control-label">折扣</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'user.level' $level}
            <div class="input-group">
                <input type="text" name="discount" class="form-control" value="{$level['discount']}" />
                <div class="input-group-addon">折</div>
            </div>
            <span class='help-block'>请输入0.1~10之间的数字,值为空代表不设置折扣</span>
            {else}
            <div class='form-control-static'>
                {if empty($level['discount'])}
                不打折
                {else}
                {$level['discount']}折
                {/if}
            </div>
            {/if}
        </div>
    </div>
    <div class="form-group" {if $id=='default'}style="display: none;"{/if}>
        <label class="col-sm-2 control-label">状态</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'shop.adv' $item}
            <label class='radio-inline'>
                <input type='radio' name='status' value=1' {if $level['status']==1}checked{/if} /> 启用
            </label>
            <label class='radio-inline'>
                <input type='radio' name='status' value=0' {if $level['status']==0}checked{/if} /> 禁用
            </label>

            {else}
            <div class='form-control-static'>{if empty($item['status'])}隐藏{else}显示{/if}</div>
            {/if}
        </div>
    </div>
    <div class="form-group"></div>
    <div class="form-group">
        <label class="col-sm-2 control-label"></label>
        <div class="col-sm-9 col-xs-12">
            {ife 'user.level' $level}
            <input type="submit" value="提交" class="btn btn-primary"  />
            {/if}
            <input type="button" name="back" onclick='history.back()' {ifp 'user.level.add|user.level.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
        </div>
    </div>


</form>
</div>
{template '_footer'}
